package net.sf.rose.business.bean.control;

import java.util.ArrayList;
import java.util.List;

import net.sf.rose.business.bean.control.judge.JudgeBean;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;

/**
 * @author fengjian
 * @since 2014-5-20
 */
public class PanelBean {

	/** 标题 */
	@Attribute
	private String text = null;

	/** 面板的高度 */
	@Attribute
	private int height = 0;

	/** 面板的宽度 */
	@Attribute
	private int width = 0;

	/** 面板的行数 */
	@Attribute(required = false)
	private int rows = 0;

	/** 面板的列数 */
	@Attribute(required = false)
	private int cols = 0;

	/** 权限配置 */
	@Element(required = false)
	private JudgeBean judge = null;

	/** 表格组件 */
	@Element(required = false)
	private TableBean table = null;

	/** 面板的所有组件 */
	@ElementList(name = "controls", required = false)
	private List<ControlBean> controls = new ArrayList<ControlBean>();

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	public int getCols() {
		return cols;
	}

	public void setCols(int cols) {
		this.cols = cols;
	}

	public List<ControlBean> getControls() {
		return controls;
	}

	public void setControls(List<ControlBean> controls) {
		this.controls = controls;
	}

	public ControlBean getControl(String name) {
		for (ControlBean bean : controls) {
			if (bean.getName().equals(name)) {
				return bean;
			}
		}
		return null;
	}

	public void removeControl(String name) {
		for (ControlBean bean : controls) {
			if (bean.getName().equals(name)) {
				controls.remove(bean);
				return;
			}
		}
	}

	public TableBean getTable() {
		return table;
	}

	public void setTable(TableBean table) {
		this.table = table;
	}

	public JudgeBean getJudge() {
		return judge;
	}

	public void setJudge(JudgeBean judge) {
		this.judge = judge;
	}
}
